﻿<UserControl
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:lex="clr-namespace:WPFLocalizeExtension.Extensions;assembly=WPFLocalizeExtension"
             xmlns:converters="clr-namespace:UI.Resources.Converters" x:Class="UI.Resources.Controls.ColumnsSelector"
             mc:Ignorable="d" 
             x:Name="SwitchControl"
             d:DesignHeight="300" d:DesignWidth="300">

	<UserControl.Resources>
		<converters:InverseNullToVisibilityConverter x:Key="InverseNullToVisibilityConverter"/>
	</UserControl.Resources>

	<Grid Margin="11">
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="*"/>
			<ColumnDefinition Width="Auto"/>
			<ColumnDefinition Width="*"/>
		</Grid.ColumnDefinitions>
		<DockPanel>
			<StackPanel DockPanel.Dock="Bottom" >
				<TextBlock Text="{lex:Loc RAE:Strings:Custom_column}" Margin="0 5 0 0"/>
				<TextBox Margin="0 5 0 0" Height="24" x:Name="NewTextBox" VerticalContentAlignment="Center" KeyDown="NewTextBoxKeyDown"/>
			</StackPanel>
			<TreeView ItemsSource="{Binding SourceItems, ElementName=SwitchControl}" x:Name="SourceListBox" MouseDoubleClick="TreeViewItemMouseDoubleClick">
				<TreeView.ItemContainerStyle>
					<Style TargetType="{x:Type TreeViewItem}">
						<EventSetter Event="MouseDoubleClick" Handler="TreeViewItemMouseDoubleClick" />
					</Style>
				</TreeView.ItemContainerStyle>
				<TreeView.ItemTemplate>
					<HierarchicalDataTemplate ItemsSource="{Binding Columns}">
						<TextBlock Text="{Binding Name}"/>

						<HierarchicalDataTemplate.ItemTemplate>
							<DataTemplate>
								<TextBlock Text="{Binding Name}"/>
							</DataTemplate>
						</HierarchicalDataTemplate.ItemTemplate>
					</HierarchicalDataTemplate>
				</TreeView.ItemTemplate>
			</TreeView>
		</DockPanel>
		<StackPanel Grid.Column="1" VerticalAlignment="Center">
			<Button Content="&gt;" Margin="3" Padding="5 0" Click="ToResultButtonClick"/>
			<Button Content="&lt;" Margin="3" Padding="5 0" Click="ToSourceButtonClick"/>
		</StackPanel>
		<ListBox Grid.Column="2" ItemsSource="{Binding ResultItems, ElementName=SwitchControl}" x:Name="ResultListBox"/>
	</Grid>
</UserControl>
